unit RotinasGerais;

interface

// inclui aqui AS api utilizadas
uses SysUtils, SqlExpr; //, StrUtils, SysUtils, Windows;

type
  VGetDataRet = array[0..25] of string;

// Aqui comecao a descricao das procedures e functions criadas nesta unit
function FGetData(PSql: string; PQtValues: integer): VGetDataRet;
procedure ExecutaSQL(PSql: string);

var
  VGetVal, VParams: VGetDataRet;
  //[EBS] CONFIRMAR SE PRECISA DE TODAS estas variaveis aqui
  {*
  VFUsuario, VFGrupo: string;
  VBanco, VNomeSistema: string;
  VSaidaRel, VSaidaRelOrdem: string;
  VUserNum: integer;
  VDateSave, VDateFormat, VTimeFormat, VDateTimeSave, VTimeSave: string;
  VRetProcura, VUsuario, VUsuarioBloq, VSistIndep: string;
  *}

const
  CR = #13;       // "Enter" key, "Carriage Return"
  CRLF = #13#10;  // Carriage Return + LineFeed

implementation

uses ufrmDataModule;

// funcao para consulta no banco de dados
function FGetData(PSql: string; PQtValues: integer): VGetDataRet;
var
  VInt: integer;
  VDtSet: TSqlDataSet;
begin
  for VInt := 0 to 25 do begin
    FGetData[VInt] := '';
  end;
  VDtSet := TSqlDataSet.Create(nil);
  VDtSet.SQLConnection := MConn.DBConn;
  VDtSet.CommandType := ctQuery;
  VDtSet.CommandText := PSql;
  VDtSet.Open;
  if not VDtSet.Eof then begin
    for VInt := 1 to PQtValues do begin
      FGetData[VInt] := VDtSet.Fields[VInt-1].AsString;
    end;
  end;
  VDtSet.Close;
  VDtSet.Destroy;
end;

// executa uma query sql
procedure ExecutaSQL(PSql: string);
var
  VDtSet: TSqlDataSet;
begin
  VDtSet := TSqlDataSet.Create(nil);
  VDtSet.SQLConnection := MConn.DBConn;
  VDtSet.CommandType := ctQuery;
  VDtSet.CommandText := PSql;
  VDtSet.ExecSQL(true);
  VDtSet.Destroy;
end;

end.
